#include<iostream>
#include<unordered_map>

using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
ll arr[N];

unordered_map<ll, ll>mp;

int main()
{
	ll n, c; cin >> n >> c;
	 for (int i = 1 ; i <= n;i++)
	{
		 cin >> arr[i];
		 mp[arr[i]]++;
	}
	 ll ret = 0;
	 for (int i = 1; i <= n; i++)
	 {
		 ret += mp[c + arr[i]];
	 }
	 cout << ret;
	return 0;
}
